package com.demo;

/*
线程中断
 */
class MyThread extends Thread {
    @Override
    public void run() {
        while (!isInterrupted()) {
            System.out.println("123");
        }
    }
}

public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        MyThread t1 = new MyThread();

        t1.start();
        Thread.sleep(3000);
        t1.interrupt();
    }
}
